home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Periodicals / CSMP / csmp-v3-032.txt < prev   
Internet Message Format  |  1994-06-09  |  50KB

  1. From: pottier@clipper.ens.fr (Francois Pottier)
  2. Subject: csmp-digest-v3-032
  3. Date: Mon, 30 May 94 14:02:04 MET DST
  4.  
  5. C.S.M.P. Digest             Mon, 30 May 94       Volume 3 : Issue 32
  6.  
  7. Today's Topics:
  8.  
  9.         Are there any Disassemblers for Mac?
  10.         Drawing strings vertically.
  11.         I HATE GWorlds!
  12.         Is FSpExchangeFiles still broken?
  13.         Looping sounds
  14.         PPC Toolbox GetDefaultUser() bug
  15.         SU3.0 programming tip
  16.  
  17.  
  18.  
  19. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  20. (pottier@clipper.ens.fr).
  21.  
  22. The digest is a collection of article threads from the internet newsgroup
  23. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  24. regularly and want an archive of the discussions.  If you don't know what a
  25. newsgroup is, you probably don't have access to it.  Ask your systems
  26. administrator(s) for details.  If you don't have access to news, you may
  27. still be able to post messages to the group by using a mail server like
  28. anon.penet.fi (mail help@anon.penet.fi for more information).
  29.  
  30. Each issue of the digest contains one or more sets of articles (called
  31. threads), with each set corresponding to a 'discussion' of a particular
  32. subject.  The articles are not edited; all articles included in this digest
  33. are in their original posted form (as received by our news server at
  34. nef.ens.fr).  Article threads are not added to the digest until the last
  35. article added to the thread is at least two weeks old (this is to ensure that
  36. the thread is dead before adding it to the digest).  Article threads that
  37. consist of only one message are generally not included in the digest.
  38.  
  39. The digest is officially distributed by two means, by email and ftp.
  40.  
  41. If you want to receive the digest by mail, send email to listserv@ens.fr
  42. with no subject and one of the following commands as body:
  43.     help                        Sends you a summary of commands
  44.     subscribe csmp-digest Your Name    Adds you to the mailing list
  45.     signoff csmp-digest            Removes you from the list
  46. Once you have subscribed, you will automatically receive each new
  47. issue as it is created.
  48.  
  49. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  50. Questions related to the ftp site should be directed to
  51. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  52. digest are available there.
  53.  
  54. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  55.  
  56.  
  57. -------------------------------------------------------
  58.  
  59. >From fd ()
  60. Subject: Are there any Disassemblers for Mac?
  61. Date: 13 May 1994 21:31:30 GMT
  62. Organization: Northwestern University, Evanston, IL  USA
  63.  
  64.  
  65. I was wondering... is there a program out there
  66. which can take, say, a CODE or MDEF etc resource and
  67. at the very least, disassemble it into the 680x0 instructions?
  68.  
  69. Even better if it could do more things, like maybe tell you
  70. what toolbox trap a jump was to, etc.
  71.  
  72. Does Macsbug let you do this?
  73.  
  74. any info/comments would be greatly appreciated on this or
  75. any other tool that helps you dissect code.
  76.  
  77. many thanks in advance,
  78. usman
  79.  
  80. +++++++++++++++++++++++++++
  81.  
  82. >From ray@netcom.com (Ray Fischer)
  83. Date: Sat, 14 May 1994 03:18:50 GMT
  84. Organization: Netcom. San Jose, California
  85.  
  86. fd () writes ...
  87. >I was wondering... is there a program out there
  88. >which can take, say, a CODE or MDEF etc resource and
  89. >at the very least, disassemble it into the 680x0 instructions?
  90.  
  91. Yes, and a nice (and free) tool it is, too.
  92.  
  93. Look for the CODE editor for ResEdit.  It disassembles most code
  94. resource types and has some nifty features.  It's probably on
  95. ftp.apple.com or sumex.stanford.edu (or one of its mirror sites).
  96.  
  97. -- 
  98. Ray Fischer          "Men become civilized, not in proportion to their
  99. ray@netcom.com        willingness to believe, but in their readiness
  100.                       to doubt."  -- H. L. Mencken
  101.  
  102. +++++++++++++++++++++++++++
  103.  
  104. >From kenlong@netcom.com (Ken Long)
  105. Date: Sat, 14 May 1994 07:16:29 GMT
  106. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  107.  
  108. The ResEdit 'CODE' editor is good.  Once installed (the resources pasted 
  109. into ResEdit's pref's file) it will open a disassembled representation of 
  110. the 'CODE' resources by double-clicking on the resource in the picker 
  111. window.  You can't edit from within the disassble window - you must open 
  112. the ID with the hex editor to do that.  but the "edit" window is great 
  113. for navigating and "tree climbing" through the program.  It does jumps 
  114. within the 'CODE' resource - even ID to ID.
  115.  
  116. If you want the port output in a text file, you have to copy/paste 
  117. (unless someone knows of another way).  I do this by opening the editor 
  118. window, clicking in pageDown 18 times (LC/10MB/12"monitor) then holding 
  119. down shift and clicking once in the hex at the screen right.  Then 
  120. copy to clip.  Then I click in a new Think C editor window I already had 
  121. set up and paste into it.  Save, then click in the 'CODE' editor window 
  122. anh hit right-arrow once.  Then hit pageDown 18 more times.  Any more and 
  123. ResEdit barfs up a "can't" alert.
  124.  
  125. Continue this sequence until you are at the end.
  126.  
  127. Faster and easier, but less elegant output, is DisAsm 3.1.  You open the 
  128. file, select the resource (default is 'CODE' and you can save output to a 
  129. text file.
  130.  
  131. A few notches above this is RSC_Viewer II.  I will save a 'CODE' ID at a 
  132. time to a text file.  The output is closest to ResEdit output.
  133.  
  134. Then the big-money diassembler is MacNosy.  It does a better job at a lot 
  135. of things than other disassemblers, but a lousy job at some things.  it 
  136. leaves out most of the "(sp)" ((A7))s and puts "PUSH" and "POP" in where 
  137. others (including ResEdit) put something else.  But it lists generic 
  138. variables and parameters before the routines they go in, which no other 
  139. disassembler I've seen does.  Not as good as "short one, two, three" but 
  140. just the fact that it has locals or parameters, their order and size.  
  141. Better than nothing.
  142.  
  143. It also lists out globals in a similar way.  I've set Think C to generate 
  144. a map during a build, built the app., ran it through Nosy and compared 
  145. the map with the Nosy output.  It tracks.  Of course, I have a lot to 
  146. learn, so it may provide more info than I can see.
  147.  
  148. Nosy also extracts strings, and says where in the code they go.
  149.  
  150. When I got the asm source for Orion, I ran Orion through Nosy and it 
  151. tracked exactly with the source.  I did not get the star table when I 
  152. first got the source, so I made them with what I got out of Nosy output.  
  153. Then, later, when I did get them, and compared them with the ones I made, 
  154. they were the same.  Cool!
  155.  
  156. Those four are the main ones.  The MPW disassembler, I'm told, was used 
  157. as the basis for the ResEdit 'CODE' editor.
  158.  
  159. I have some MSQBasic source for an old console dumping disassembler.  
  160. It's not a hex dumper, but outputs instructions and operands.  I'd like 
  161. to get some C source for one.
  162.  
  163. That's about it - those 5.  ResEdit, DisAsm 3.1, RSC_Viewer II, MPW and 
  164. MacNosy.  There may be more I've not seen.
  165.  
  166. -Ken-
  167.  
  168. +++++++++++++++++++++++++++
  169.  
  170. >From Vampire@crypt.demon.co.uk (Vampire)
  171. Date: Sat, 14 May 1994 16:25:37 GMT
  172. Organization: Pennangalan Software
  173.  
  174.  
  175. In article <fd-130594162741@cmac177.acns.nwu.edu> fd () writes:
  176. >
  177. >I was wondering... is there a program out there
  178. >which can take, say, a CODE or MDEF etc resource and
  179. >at the very least, disassemble it into the 680x0 instructions?
  180. >
  181. >Even better if it could do more things, like maybe tell you
  182. >what toolbox trap a jump was to, etc.
  183. >
  184. Yes, there is a Disassembler extension for ResEdit 2.1 that does everything you
  185. mention.
  186.  
  187. Vampire
  188.  
  189. =============================================================================
  190.                                   |"If I knock on your door, you're a fool;
  191.          VAMPIRE                  | if you invite me in, you're a dead fool"
  192.   (Pennangalan Software)          |  My dust resides @crypt.demon.co.uk
  193. =============================================================================
  194.  
  195. +++++++++++++++++++++++++++
  196.  
  197. >From peirce@outpost.SF-Bay.org (Michael Peirce)
  198. Date: Sat, 14 May 94 15:52:12 PST
  199. Organization: Peirce Software, Inc.
  200.  
  201.  
  202. In article <fd-130594162741@cmac177.acns.nwu.edu> (comp.sys.mac.programmer), fd () writes:
  203. > I was wondering... is there a program out there
  204. > which can take, say, a CODE or MDEF etc resource and
  205. > at the very least, disassemble it into the 680x0 instructions?
  206. > Even better if it could do more things, like maybe tell you
  207. > what toolbox trap a jump was to, etc.
  208. > Does Macsbug let you do this?
  209. > any info/comments would be greatly appreciated on this or
  210. > any other tool that helps you dissect code.
  211.  
  212. Two come to mind:
  213.  
  214. (1) ResEdit has a CODE editor (really a viewer) that disassembles
  215. CODE, INIT, WDEF, and more code resources.  It's pretty god really.
  216.  
  217. (2) MacNosey from Jasik Designs.  This is the industrial strength
  218. disassembler.  It it invaluable if you are really going to, err, well,
  219. I'll say it, reverse engineer something :-)
  220.  
  221. __ Michael Peirce        __ peirce@outpost.sf-bay.org
  222. __ Peirce Software, Inc. __ 719 Hibiscus Place, Suite 301
  223. __                       __ San Jose, California USA 95117-1844
  224. __ Makers of: Smoothie & __ voice: +1.408.244.6554 fax: +1.408.244.6882
  225. __    Peirce Print Tools __ AppleLink: peirce & AOL: AFC Peirce
  226.  
  227. ---------------------------
  228.  
  229. >From kenlong@netcom.com (Ken Long)
  230. Subject: Drawing strings vertically.
  231. Date: Sat, 14 May 1994 22:09:15 GMT
  232. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  233.  
  234. /* 
  235. This is a little thing I tossed together when I saw a c.s.m.p.
  236. message requesting source for writing vertical text.  There may have 
  237. been a reply I missed, but if not, this source will do.
  238.  
  239. Add MacTraps and ANSI (for strlen) and you're cookin'  The vertical
  240. text routine came from the SplatMaster Pascal source, by Jon Benton, 
  241. which I'm porting to Think C.  It doesn't totally run yet, otherwise
  242. I'd post it, too (though not here).
  243.  
  244. Anyway, as stated below, vertical strings are excellent for scroll
  245. labels, as well as about box goodies, vertical progress bars, etc.
  246.  
  247. Enjoy!
  248. */
  249.  
  250. // VerticalText.c
  251.  
  252. MenuHandle    appleMenu, fileMenu, editMenu;
  253.  
  254. enum {
  255.     appleID = 1,
  256.     fileID,
  257.     editID
  258. };
  259.  
  260. enum {
  261.     openItem = 1,
  262.     closeItem,
  263.     quitItem = 4
  264. };
  265.  
  266.  
  267. WindowPtr    genericWindow;
  268. Rect        dragRect;
  269. Rect        windowBounds = { 20, 0, 384, 512}; 
  270. Rect        strRect ={5, 20, 364, 40};
  271. int            width = 1;
  272.  
  273. // Prototypes.
  274.  
  275. void    SetUpWindow (void);
  276. void    DrawTheStrings (short active);
  277. void    SetUpMenus (void);
  278. void    AdjustMenus (void);
  279. static    enable (MenuHandle menu, short item, short ok);
  280. void    HandleMenu (long mSelect);
  281. void    InitMacintosh (void);
  282. void    HandleMouseDown (EventRecord *theEvent);
  283. void    HandleEvent (void);
  284. int        main (void);
  285.  
  286. void SetUpWindow (void)
  287. {
  288.     dragRect = qd.screenBits.bounds;
  289.     
  290.     genericWindow = NewWindow (0L, &windowBounds, "\pWhat about it?", true, noGrowDocProc, (WindowPtr) -1L, true, 0);
  291.     SetPort (genericWindow);
  292. }
  293.  
  294. void SetUpMenus (void)
  295. {
  296.     InsertMenu (appleMenu = NewMenu (appleID, "\p\024"), 0);
  297.     InsertMenu (fileMenu = NewMenu (fileID, "\pFile"), 0);
  298.     InsertMenu (editMenu = NewMenu (editID, "\pEdit"), 0);
  299.     DrawMenuBar ();
  300.     AddResMenu (appleMenu, 'DRVR');
  301.     AppendMenu (fileMenu, "\pOpen/O;Close/W;(-;Quit/Q");
  302.     AppendMenu (editMenu, "\pUndo/Z; (-;Cut/X;Copy/C;Paste/V;Clear");
  303. }
  304.  
  305. void VerticalString (Rect word_rect, Str255 word_string)
  306. {
  307.     #define center 5    // center of label is 'center' pixels from left of rect.
  308.     
  309.     short numChars, leading, stringCenter, x, curVert;
  310.     FontInfo fInfo;
  311.  
  312.     TextFont (monaco);
  313.     TextSize (9);
  314.     TextFace (0);
  315.     GetFontInfo (&fInfo);
  316.     leading = fInfo.ascent + fInfo.descent + fInfo.leading;
  317.     stringCenter = word_rect.left - center;
  318.  
  319. //    ForeColor (redColor);    // oldStyle color.
  320.     curVert = word_rect.top + leading;    // primed for first character.
  321.     numChars = strlen (word_string);
  322.     for (x = 1; x < numChars; x++)
  323.     {
  324.         MoveTo (stringCenter - (CharWidth (word_string[x]) / 2), 
  325.                 curVert);
  326.         DrawChar ((char) word_string[x]);
  327.         curVert = curVert + leading;
  328.     }
  329. //    ForeColor (blackColor);    // oldStyle color.
  330. }    // VerticalString.
  331.  
  332. void DrawTheStrings (short active)
  333. {
  334.     int        color = true;
  335.     
  336.     SetPort (genericWindow);
  337.     
  338.     VerticalString (strRect, "\pMy name is Long but this is ");
  339.     OffsetRect (&strRect, 20, 0);
  340.     VerticalString (strRect, "\pnot Chinese writing.");
  341.     
  342.     OffsetRect (&strRect, 40, 0);
  343.     VerticalString (strRect, "\pSuperman\0");
  344.     OffsetRect (&strRect, 20, 0);
  345.     VerticalString (strRect, "\pStrange visitor\0");
  346.     OffsetRect (&strRect, 20, 0);
  347.     VerticalString (strRect, "\pfrom another planet\0");
  348.     OffsetRect (&strRect, 20, 0);
  349.     VerticalString (strRect, "\pwho came to Earth  beyond\0");
  350.     OffsetRect (&strRect, 20, 0);
  351.     VerticalString (strRect, "\pwith powers and abilities far\0");
  352.     OffsetRect (&strRect, 20, 0);
  353.     VerticalString (strRect, "\pbeyond those of mortal men.\0");
  354.     
  355.     OffsetRect (&strRect, 40, 0);
  356.     VerticalString (strRect, "\pThe VerticalString Routine was\0");
  357.     OffsetRect (&strRect, 20, 0);
  358.     VerticalString (strRect, "\ptaken from 'SplatMaster' Pascal\0");
  359.     OffsetRect (&strRect, 20, 0);
  360.     VerticalString (strRect, "\psource code. It was ported to\0");
  361.     OffsetRect (&strRect, 20, 0);
  362.     VerticalString (strRect, "\pThink C by Kenneth A. Long in\0");
  363.     OffsetRect (&strRect, 20, 0);
  364.     VerticalString (strRect, "\pmid 1992 and put into this demo\0");
  365.     OffsetRect (&strRect, 20, 0);
  366.     VerticalString (strRect, "\pin May of 1994 for YOUR use and\0");
  367.     OffsetRect (&strRect, 20, 0);
  368.     VerticalString (strRect, "\p enjoyment.  Please do so!\0");
  369.     OffsetRect (&strRect, 40, 0);
  370.     VerticalString (strRect, "\pVertical strings are excellent\0");
  371.     OffsetRect (&strRect, 20, 0);
  372.     VerticalString (strRect, "\pfor labeling vertical scrolls.\0");
  373.     OffsetRect (&strRect, 40, 0);
  374.     VerticalString (strRect, "\pBullseye was used for the shell.\0");
  375.     OffsetRect (&strRect, 20, 0);
  376.     VerticalString (strRect, "\pJon Benton wrote SplatMaster.\0");
  377.     OffsetRect (&strRect, 20, 0);
  378.     VerticalString (strRect, "\pVertical String Demo is PD.\0");
  379. }
  380.  
  381. void AdjustMenus (void)
  382. {
  383.     register WindowPeek wp = (WindowPeek) FrontWindow ();
  384.     short kind = wp ? wp->windowKind : 0;
  385.     Boolean DA = kind < 0;
  386.     
  387.     enable (editMenu, 1, DA);
  388.     enable (editMenu, 3, DA);
  389.     enable (editMenu, 4, DA);
  390.     enable (editMenu, 5, DA);
  391.     enable (editMenu, 6, DA);
  392.     
  393.     enable (fileMenu, openItem, ! ((WindowPeek) genericWindow)->visible);
  394.     enable (fileMenu, closeItem, DA || ((WindowPeek) genericWindow)->visible);
  395. }
  396.  
  397. static enable (MenuHandle menu, short item, short ok)
  398. {
  399.     if (ok)
  400.         EnableItem (menu, item);
  401.     else
  402.         DisableItem (menu, item);
  403. }
  404.  
  405. void HandleMenu (long mSelect)
  406. {
  407.     int            menuID = HiWord (mSelect);
  408.     int            menuItem = LoWord (mSelect);
  409.     Str255        name;
  410.     GrafPtr        savePort;
  411.     WindowPeek    frontWindow;
  412.     
  413.     switch (menuID)
  414.     {
  415.         case    appleID:
  416.             GetPort (&savePort);
  417.             GetItem (appleMenu, menuItem, name);
  418.             OpenDeskAcc (name);
  419.             SetPort (savePort);
  420.         break;
  421.         
  422.         case    fileID:
  423.             switch (menuItem)
  424.             {
  425.                 case    openItem:
  426.                     ShowWindow (genericWindow);
  427.                     SelectWindow (genericWindow);
  428.                 break;
  429.                               
  430.                 case    closeItem:
  431.                     if ((frontWindow = (WindowPeek) FrontWindow ()) == 0L)
  432.                 break;
  433.             
  434.                 if (frontWindow->windowKind < 0)
  435.                     CloseDeskAcc (frontWindow->windowKind);
  436.                 else 
  437.                     if (frontWindow = (WindowPeek) genericWindow)
  438.                         HideWindow (genericWindow);
  439.                       break;
  440.                       
  441.                 case    quitItem:
  442.                     ExitToShell ();
  443.                 break;
  444.             }
  445.         break;
  446.                   
  447.         case    editID:
  448.             if (!SystemEdit (menuItem-1))
  449.                 SysBeep (5);
  450.         break;
  451.     }
  452. }
  453.  
  454. void InitMacintosh (void)
  455. {
  456.     MaxApplZone ();
  457.     
  458.     InitGraf (& (qd.thePort));
  459.     InitFonts ();
  460.     FlushEvents (everyEvent, 0);
  461.     InitWindows ();
  462.     InitMenus ();
  463.     TEInit ();
  464.     InitDialogs (0L);
  465.     InitCursor ();
  466. }
  467.  
  468. void HandleMouseDown (EventRecord    *theEvent)
  469. {
  470.     WindowPtr    theWindow;
  471.     int            windowCode = FindWindow (theEvent->where, &theWindow);
  472.     
  473.     switch (windowCode)
  474.     {
  475.         case inSysWindow: 
  476.             SystemClick (theEvent, theWindow);
  477.         break;
  478.     
  479.         case inMenuBar:
  480.             AdjustMenus ();
  481.             HandleMenu (MenuSelect (theEvent->where));
  482.         break;
  483.     
  484.         case inDrag:
  485.             if (theWindow == genericWindow)
  486.                 DragWindow (genericWindow, theEvent->where, &dragRect);
  487.         break;
  488.         
  489.         case inContent:
  490. //            if (theWindow == genericWindow)
  491. //            {
  492. //                if (theWindow != FrontWindow ())
  493. //                    SelectWindow (genericWindow);
  494. //                else
  495. //                    InvalRect (&genericWindow->portRect);
  496. //            }
  497.         break;
  498.         
  499.         case inGoAway:
  500.             if (theWindow == genericWindow && 
  501.                 TrackGoAway (genericWindow, theEvent->where))
  502.                 HideWindow (genericWindow);
  503.         break;
  504.     }
  505. }
  506.  
  507. void HandleEvent (void)
  508. {
  509.     int            ok;
  510.     EventRecord    theEvent;
  511.  
  512.     HiliteMenu (0);
  513.     SystemTask ();        /* Handle desk accessories */
  514.     
  515.     ok = GetNextEvent (everyEvent, &theEvent);
  516.     if (ok)
  517.     switch (theEvent.what)
  518.     {
  519.         case mouseDown:
  520.             HandleMouseDown (&theEvent);
  521.         break;
  522.             
  523.         case keyDown: 
  524.         case autoKey:
  525.         if ((theEvent.modifiers & cmdKey) != 0)
  526.         {
  527.             AdjustMenus ();
  528.             HandleMenu (MenuKey ((char) (theEvent.message & charCodeMask)));
  529.         }
  530.         break;
  531.             
  532.         case updateEvt:
  533.             BeginUpdate (genericWindow);
  534.             DrawTheStrings (((WindowPeek) genericWindow)->hilited);
  535.             EndUpdate (genericWindow);
  536.         break;
  537.         
  538.         case activateEvt:
  539.             InvalRect (&genericWindow->portRect);
  540.         break;
  541.     }
  542. }
  543.  
  544. main ()
  545. {
  546.     InitMacintosh ();
  547.     SetUpMenus ();
  548.     SetUpWindow ();
  549.     
  550.     for (;;)
  551.         HandleEvent ();
  552. }
  553.  
  554.  
  555. +++++++++++++++++++++++++++
  556.  
  557. >From kenlong@netcom.com (Ken Long)
  558. Date: Sun, 15 May 1994 06:16:46 GMT
  559. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  560.  
  561. I don't care how many times I check it, a typo manages to get through.  
  562. Must be old-timer's disease creaping in!
  563.  
  564. The quote is:
  565.  
  566. "Superman!  Strange visitor, from another planet, who came to Earth with 
  567. powers and abilities far beyond those of mortal men."
  568.  
  569. (no "beyond" after "Earth")
  570.  
  571. -Ken-  :|
  572.  
  573.  
  574. ---------------------------
  575.  
  576. >From mprince@mail.trincoll.edu (Matthew Prince)
  577. Subject: I HATE GWorlds!
  578. Date: 5 May 1994 05:21:30 GMT
  579. Organization: Trinity College
  580.  
  581. I'm confused.  I thought that I'd venture into the world of Offscreen
  582. GWorld drawing with my new copy of Inside Macintosh Imaging.  I thought
  583. that everything would be nice and easy.  I thought that I could have
  584. everything working in a few days, and if not, I could figure out what
  585. was wrong easily.  I was wrong.  I've set up an offscreen GWorld that
  586. has the same dimensions as my on screen window.  I think that it's set
  587. up correctly because the first time that I CopyBits from it everything
  588. works fine.  And if I CopyBits a simple image it works fine too.  But
  589. when I try to CopyBits a complex image from it once, and then change
  590. the image slightly and try to CopyBits it again, it looks as if someone
  591. has taken a shotgun to the image.  I'd say about half the pixels are
  592. there.  And while it's in the same basic shape and color of the
  593. original image, it looks as if it's had a bunch of information lost. 
  594. I'm confused.  It's late.  I'm sure this is a stupid question.  Please
  595. forgive me.  But if anyone has any idea what is going on, I'd
  596. appreciate any help they could lend.
  597.  
  598. Thanks,
  599. Matthew Prince
  600. mprince@mail.trincoll.edu
  601.  
  602. +++++++++++++++++++++++++++
  603.  
  604. >From Thomas Reed <reed@medicine.wustl.edu>
  605. Date: 6 May 1994 14:08:26 GMT
  606. Organization: Washington University
  607.  
  608. In article <2q9voq$nt1@yar.trincoll.edu> Matthew Prince,
  609. mprince@mail.trincoll.edu writes:
  610. >I'm confused.  I thought that I'd venture into the world of Offscreen
  611. >GWorld drawing with my new copy of Inside Macintosh Imaging.  I thought
  612. >that everything would be nice and easy.  I thought that I could have
  613. >everything working in a few days, and if not, I could figure out what
  614. >was wrong easily.  I was wrong.
  615.  
  616. You bet!  And you were using GWorlds -- try it with offscreen GrafPorts! 
  617. It took me two years to find information on how to do it with GrafPorts. 
  618. Of course, this was before I had access to all the wonderful information
  619. on the Internet!  So things were harder to find back then...
  620.  
  621. Anyway, I'm not sure what's going wrong with your code, but here's some
  622. source code to look at.  First, here's what I do when I want to transfer
  623. from an offscreen GWorld to an onscreen window:
  624.  
  625.     UseOffWorld(gGeneralWorld);
  626.     EraseRect(&thePort->portRect);
  627.     /* do some drawing in the offscreen GWorld */
  628.     DoneWithOffWorld(gGeneralWorld);
  629.     CopyBits(*GetGWorldPixMap(gGeneralWorld), &myWind->portBits,
  630. &myWind->portRect, &myWind->portRect, srcCopy, myWind->visRgn);
  631.  
  632. Now, many of you may not recognize the UseOffWorld and DoneWithOffWorld
  633. calls.  They're in a custom library I've written that contains code for
  634. both GWorlds and for GrafPorts.  I'll stick the entire library at the end
  635. of this message.
  636.  
  637. Hope this helps!
  638.  
  639. -Thomas
  640.  
  641. - ------- begin offscreen library ---------
  642. #define NIL        0L
  643.  
  644. /* for BitMap calls */
  645. #define kIsVisible TRUE
  646. #define kNoGoAway FALSE
  647. #define kNoWindowStorage 0L
  648. #define kFrontWindow ((WindowPtr) -1L)
  649.  
  650.  
  651. GDHandle        gOldDevice;
  652. CGrafPtr        gOldPort;
  653.  
  654. void UseOffWorld(GWorldPtr offWorlder);
  655.   /* call before drawing to offscreen GWorld */
  656. void DoneWithOffWorld(GWorldPtr offWorlder);
  657.   /* call after drawing to offscreen GWorld, before CopyBits */
  658. Boolean CreateOffscreenBitMap(GrafPtr *, Rect *);
  659. void DestroyOffscreenBitMap(GrafPtr);
  660.  
  661. void UseOffWorld(GWorldPtr offWorlder)
  662. {
  663.   GetGWorld(&gOldPort, &gOldDevice);
  664.   LockPixels(GetGWorldPixMap(offWorlder));
  665.   SetGWorld(offWorlder, NIL);
  666. }
  667.  
  668. void DoneWithOffWorld(GWorldPtr offWorlder)
  669. {
  670.   UnlockPixels(GetGWorldPixMap(offWorlder));
  671.   SetGWorld(gOldPort, gOldDevice);
  672. }
  673.  
  674. /* === BitMap routines === */
  675.  
  676. Boolean CreateOffscreenBitMap(GrafPtr *newOffscreen, Rect *inBounds)
  677. {
  678.   GrafPtr savePort;
  679.   GrafPtr newPort;
  680.  
  681.   GetPort(&savePort); /* need this to restore thePort after OpenPort */
  682.  
  683.   newPort = (GrafPtr)NewPtr(sizeof(GrafPort));/* allocate the grafPort */
  684.   if(MemError() != noErr)
  685.     return FALSE;                                            
  686.     /* failure to allocate off-screen port */
  687.  
  688.     /*    the call to OpenPort does the following:
  689.  
  690.         allocates space for visRgn (set to screenBits.bounds)
  691.         and clipRgn (set wide open)
  692.         sets portBits to screenBits
  693.         sets portRect to screenBits.bounds
  694.         etc. (see Inside Macintosh Volume 1 pages 163-164)
  695.         side effect: does a SetPort (&offScreen)
  696.     */
  697.  
  698.   OpenPort(newPort);
  699.  
  700.   /* make bitmap the size of the bounds that caller supplied */
  701.   newPort->portRect = *inBounds;
  702.   newPort->portBits.bounds = *inBounds;
  703.   RectRgn(newPort->clipRgn, inBounds);
  704.   RectRgn(newPort->visRgn, inBounds);
  705.   /* rowBytes is size of row, must be rounded up to an even number of
  706. bytes */
  707.  
  708.   newPort->portBits.rowBytes = ((inBounds->right - inBounds->left + 15)
  709. >> 4) << 1;
  710.  
  711.   /* number of bytes in BitMap is rowBytes * number of rows */
  712.   /* see notes at end of example about using NewPtr instead of NewHandle
  713. */
  714.   newPort->portBits.baseAddr = 
  715.     NewPtr(newPort->portBits.rowBytes * (long)(inBounds->bottom -
  716. inBounds->top));
  717.  
  718.   if(MemError() != noErr)
  719.   {
  720.     SetPort(savePort);
  721.     ClosePort(newPort);            /* dump the visRgn and clipRgn */
  722.     DisposPtr((Ptr)newPort);    /* dump the GrafPort */
  723.     return FALSE;    /* tell caller we failed */
  724.   }
  725.  
  726.   /* since the bits are just memory, let's clear them before we start */
  727.   EraseRect(inBounds);/* OpenPort did a SetPort(newPort) so we are OK*/
  728.   *newOffscreen = newPort;
  729.   SetPort(savePort);
  730.   return TRUE;                        /* success */
  731. }
  732.  
  733. /*
  734.     DestroyOffscreenBitMap - get rid of an off-screen bitmap created
  735.     by CreateOffscreenBitMap
  736. */
  737. void DestroyOffscreenBitMap(GrafPtr oldOffscreen)
  738. {
  739.   ClosePort(oldOffscreen);            /* dump the visRgn and clipRgn */
  740.   DisposPtr(oldOffscreen->portBits.baseAddr);    /* dump the bits */
  741.   DisposPtr((Ptr)oldOffscreen);            /* dump the port */
  742. }
  743. - ------- end offscreen library ----------
  744. =====================================================
  745. Thomas Reed                    Washington University
  746. Reed@telesphere.wustl.edu          Medical School
  747. (also:  Reed@medicine.wustl.edu)
  748. - ---------------------------------------------------
  749. Clothes make the man.  Naked people have little or no
  750. influence on society.  -- Mark Twain
  751. =====================================================
  752.  
  753. +++++++++++++++++++++++++++
  754.  
  755. >From tgaul@halcyon.com (Troy Gaul)
  756. Date: 9 May 1994 05:10:25 GMT
  757. Organization: Infinity Systems
  758.  
  759. In article <2q9voq$nt1@yar.trincoll.edu>, mprince@mail.trincoll.edu
  760. (Matthew Prince) wrote:
  761.  
  762. > I'm confused.  I thought that I'd venture into the world of Offscreen
  763. > GWorld drawing with my new copy of Inside Macintosh Imaging.  I thought
  764. > that everything would be nice and easy.  I thought that I could have
  765. > everything working in a few days, and if not, I could figure out what
  766. > was wrong easily.  I was wrong.  I've set up an offscreen GWorld that
  767. > has the same dimensions as my on screen window.  I think that it's set
  768. > up correctly because the first time that I CopyBits from it everything
  769. > works fine.  And if I CopyBits a simple image it works fine too.  But
  770. > when I try to CopyBits a complex image from it once, and then change
  771. > the image slightly and try to CopyBits it again, it looks as if someone
  772. > has taken a shotgun to the image.  I'd say about half the pixels are
  773. > there.  And while it's in the same basic shape and color of the
  774. > original image, it looks as if it's had a bunch of information lost. 
  775. > I'm confused.  It's late.  I'm sure this is a stupid question.  Please
  776. > forgive me.  But if anyone has any idea what is going on, I'd
  777. > appreciate any help they could lend.
  778.  
  779. Just to make sure this isn't the case (I don't have the New Inside Mac here
  780. to look at to see what they say about the topic):  Are you locking the
  781. GWorld's pixel map before calling CopyBits?
  782.  
  783. Also, when modifying the image between CopyBits's, are you setting and
  784. resetting the GWorld (with Get/SetGWorld)?
  785.  
  786. GWorld's really aren't that bad once you get all of these little things
  787. worked out.  Keep at it.  You'll be glad you did. (And good luck.)
  788.  
  789. _troy
  790.  
  791. +++++++++++++++++++++++++++
  792.  
  793. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  794. Date: Wed, 11 May 1994 18:41:07 GMT
  795. Organization: Apple Computer
  796.  
  797. Matthew Prince, mprince@mail.trincoll.edu writes:
  798. > I'm confused.  I thought that I'd venture into the world of Offscreen
  799. > GWorld drawing with my new copy of Inside Macintosh Imaging.  I thought
  800. > that everything would be nice and easy.  I thought that I could have
  801. > everything working in a few days, and if not, I could figure out what
  802. > was wrong easily.  I was wrong.
  803.  
  804. Matthew, for the crime of dissing GWorlds I sentence you to write offscreen
  805. color graphics code _without_ using them. (I did it once, with help from
  806. Andrew Welch. I could post some source code that would curl your hair!)
  807.  
  808. Mistakes you might be making:
  809. - Don't make assumptions about the rowBytes of the offscreen data. It often
  810. gets rounded up for efficiency. Get the rowBytes out of the pixMap and use
  811. that in all your calculations.
  812. - If you're groping into the pixel data (which is fine) make sure to do your
  813. math with longints, as things can overflow 32k pretty quickly.
  814. - Remember that the pixel data is in a handle and can move around unless you
  815. lock it down with the appropriate calls.
  816. - When drawing, you must be set to the graphics world of the destination or
  817. colors will map wrong. I.e. SetGWorld to your offscreen world when drawing to
  818. it, and SetGWorld back to the screen when drawing to the screen from your
  819. offscreen world.
  820.  
  821. I think once you figure out what mistake you're making, you'll find that
  822. GWorlds are actually pretty easy to use.
  823.  
  824. --Jens Alfke
  825.   jens_alfke@powertalk              Rebel girl, rebel girl,
  826.             .apple.com              Rebel girl you are the queen of my world
  827.  
  828. +++++++++++++++++++++++++++
  829.  
  830. >From dwareing@apanix.apana.org.au (David Wareing)
  831. Date: 10 May 94 15:28:23 GMT
  832. Organization: Apanix Public Access Unix, +61 8 373 5485 (5 lines)
  833.  
  834. tgaul@halcyon.com (Troy Gaul) writes:
  835.  
  836. >In article <2q9voq$nt1@yar.trincoll.edu>, mprince@mail.trincoll.edu
  837. >(Matthew Prince) wrote:
  838.  
  839. <tale of CopyBits woe from original poster deleted>
  840.  
  841. >Just to make sure this isn't the case (I don't have the New Inside Mac here
  842. >to look at to see what they say about the topic):  Are you locking the
  843. >GWorld's pixel map before calling CopyBits?
  844.  
  845. I may be utterly wrong on this, and someone please correct me if I am, but
  846. I believe that CopyBits locks the PixMaps for you. But still, I guess its
  847. good programming practice to lock them anyway.
  848.  
  849. >Also, when modifying the image between CopyBits's, are you setting and
  850. >resetting the GWorld (with Get/SetGWorld)?
  851.  
  852. My money's on this one. Either that or the wrong rects are inadvertently
  853. being used after the GWorld PixMap has been altered, and CopyBits is
  854. scaling the image or otherwise screwing it up.
  855.  
  856. >GWorld's really aren't that bad once you get all of these little things
  857. >worked out.  Keep at it.  You'll be glad you did. (And good luck.)
  858.  
  859. Dead right. There's a hell of a lot more things to go wrong if you had to
  860. create and maintain your offscreen PixMaps by yourself. In fact, the only
  861. real obstacle to learning to use GWorlds is learning to use CopyBits
  862. properly first. In comparison, GWorlds are a breeze and easily one of the
  863. best things Apple ever came up with in the graphics dept.
  864.  
  865. --
  866. David Wareing
  867. Adelaide, South Australia
  868. Mac Games & Multimedia Development        dwareing@apanix.apana.org.au
  869. - --------------------------------------------------------------------
  870.  
  871. +++++++++++++++++++++++++++
  872.  
  873. >From forrest@hprnd.rose.hp.com (Forrest Tanaka)
  874. Date: 16 May 1994 15:45:48 GMT
  875. Organization: Hewlett-Packard, Roseville Networks Division
  876.  
  877. In article <dwareing.768583703@apanix.apana.org.au>
  878. dwareing@apanix.apana.org.au (David Wareing) writes:
  879.  
  880. > tgaul@halcyon.com (Troy Gaul) writes:
  881. > >In article <2q9voq$nt1@yar.trincoll.edu>, mprince@mail.trincoll.edu
  882. > >(Matthew Prince) wrote:
  883. > >Just to make sure this isn't the case (I don't have the New Inside Mac here
  884. > >to look at to see what they say about the topic):  Are you locking the
  885. > >GWorld's pixel map before calling CopyBits?
  886. > I may be utterly wrong on this, and someone please correct me if I am, but
  887. > I believe that CopyBits locks the PixMaps for you. But still, I guess its
  888. > good programming practice to lock them anyway.
  889. >
  890.  
  891.     There are two issues here.  One is locking the GWorld's pixels, and
  892. one is locking the GWorld's PixMap.  You *must* lock a GWorld's pixels
  893. before drawing into a GWorld, but you probably don't have to lock a
  894. GWorld's PixMap at any time.
  895.  
  896.     You must lock a GWorld's pixels because the pixel image of every
  897. GWorld is created as a relocatable block that's MoveHHi'd right after
  898. allocation.  It just floats there like any other handle until you call
  899. LockPixels which locks the pixel image wherever it is in memory so that
  900. you can draw into it.  As soon as you feel you're done drawing into it
  901. for now, you call UnlockPixels so that it can move in memory again. 
  902. Remember, pixel images can be *very* big if you ask for a big GWorld,
  903. so don't be surprised if you find big delays as your pixel image is
  904. moved around.  There might be times that you want to lock your pixel
  905. images just to be sure 10MB doesn't have to be moved in memory when you
  906. don't want it to.
  907.  
  908.     You probably don't ever have to lock a GWorld's PixMap, nor any
  909. PixMap for that matter.  Color QuickDraw was designed so that you never
  910. have to lock a PixMap--all Color QuickDraw drawing routines expect that
  911. they're unlocked, so they do what they can to avoid moving them at a
  912. bad time.  When I was in Apple DTS, I did find a bug where CopyBits had
  913. a very small but potential chance to move a PixMap structure and not
  914. take the fact that it moved into account.  This can only happen if you
  915. have a Picture open at the time.  I don't know if this was ever fixed. 
  916. If you want to experiment with this one, try a simple program with heap
  917. scramble on in your low-level debugger of choice.
  918.  
  919. > >GWorld's really aren't that bad once you get all of these little things
  920. > >worked out.  Keep at it.  You'll be glad you did. (And good luck.)
  921. > Dead right. There's a hell of a lot more things to go wrong if you had to
  922. > create and maintain your offscreen PixMaps by yourself. In fact, the only
  923. > real obstacle to learning to use GWorlds is learning to use CopyBits
  924. > properly first. In comparison, GWorlds are a breeze and easily one of the
  925. > best things Apple ever came up with in the graphics dept.
  926. >
  927.  
  928.     I third that--it's more than worth it to try to get GWorld's
  929. working.  Having seen the source code to GWorlds, I can assure you that
  930. they're not that magic if you don't have a QuickDraw accelerator card,
  931. and they're really fast if you do.  If you use GWorlds, you can save
  932. yourself a lot of coding.
  933.  
  934.  
  935. > --
  936. > David Wareing
  937. > Adelaide, South Australia
  938. > Mac Games & Multimedia Development        dwareing@apanix.apana.org.au
  939. > ----------------------------------------------------------------------
  940.  
  941.  
  942. -- Forrest Tanaka
  943. Hewlett-Packard, Roseville Networks Division
  944. Speaking on behalf of myself.
  945.  
  946. ---------------------------
  947.  
  948. >From partingt@fwi.uva.nl (Vincent Partington)
  949. Subject: Is FSpExchangeFiles still broken?
  950. Date: 13 May 1994 11:43:39 GMT
  951. Organization: FWI, University of Amsterdam
  952.  
  953. Hi,
  954.  
  955. I got a code-snippet from umich-mac last week which contains some code to
  956. do FSpExchangeFiles for volumes that don't support it (CAP a.o.).
  957. It came with a message from Jim Luther to Jon W{tte in which Jim said
  958. FSpExchangeFiles was broken on some third-party servers (and AU/X?) so
  959. he advised you to program around this bug with the code he supplied.
  960. I don't like cramming large bits of code into my program to fix a bug in the
  961. System software (just like the System shouldn't work around bugs of known
  962. programs...) so my questions is: is all this still necessary?
  963.  
  964. Vincent.
  965. -- 
  966. My opinions are not my own. I copy them    | Internet : partingt@fwi.uva.nl
  967. from books, television, video, the net,    |            vincent@tnc.nl
  968. my friends, my parents, my teachers and    | FidoNet  : 2:281/202.15
  969. and numerous other contributors.           | NeST     : 90:500/202.15
  970.  
  971. +++++++++++++++++++++++++++
  972.  
  973. >From zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
  974. Date: 13 May 1994 14:51:43 GMT
  975. Organization: Bucknell University, Lewisburg, Pa.
  976.  
  977. >I got a code-snippet from umich-mac last week which contains some code to
  978. >do FSpExchangeFiles for volumes that don't support it (CAP a.o.).
  979. >It came with a message from Jim Luther to Jon W{tte in which Jim said
  980. >FSpExchangeFiles was broken on some third-party servers (and AU/X?) so
  981. >he advised you to program around this bug with the code he supplied.
  982. >I don't like cramming large bits of code into my program to fix a bug in the
  983. >System software (just like the System shouldn't work around bugs of known
  984. >programs...) so my questions is: is all this still necessary?
  985. >
  986. >Vincent.
  987.  
  988. Why not use PBHGetVolParms to find out if the volume supports
  989. FSpExchangeFiles?  (That is, the bHasFileIDs bit of vMAttrib is set.)
  990. If it does, use it.  Otherwise, save without it.  There's one thing to
  991. watch out for though.  AUX 3.0 will tell you it has file IDs when it
  992. fact it doesn't.  I got a message from someone at Apple that said this
  993. is fixed in AUX 3.0.1 and later.
  994.  
  995. Rick Zaccone
  996. --
  997. zaccone@bucknell.edu
  998.  
  999.  
  1000. +++++++++++++++++++++++++++
  1001.  
  1002. >From jumplong@aol.com (Jump Long)
  1003. Date: 14 May 1994 03:02:53 -0400
  1004. Organization: America Online, Inc. (1-800-827-6364)
  1005.  
  1006. In article <2qvp5b$pp6@hermes.fwi.uva.nl>, partingt@fwi.uva.nl (Vincent
  1007. Partington) writes:
  1008.  
  1009. >I got a code-snippet from umich-mac last week which contains some code to
  1010. >do FSpExchangeFiles for volumes that don't support it
  1011. >...
  1012. >is all this still necessary?
  1013.  
  1014. FSpExchangeFiles is fixed by System Update 3.0.  However, unless you can ensure
  1015. that *all* users of your code update their systems, you need to include the
  1016. work-around code.
  1017.  
  1018. The latest and greatest version of the FSpExchangeFiles work-around,
  1019. FSpExchangeFilesCompat(),  can be found in MoreFiles 1.1 or later, the DTS
  1020. sample code/library that I wrote.  You can find it in the FSpCompat.c file.  My
  1021. code checks to see if the bug has been fixed and if not, does everything the
  1022. right way.  The fix will add around 800 bytes to your application (if you copy
  1023. just the routines related to FSpExchangeFiles into your code) - well worth it
  1024. if you depend on FSpExchangeFiles doing the right thing.
  1025.  
  1026. If you really don't want to add that code, then use PBExchangeFiles instead of
  1027. FSpExchangeFiles. PBExchangeFiles only works on volumes that support file
  1028. reference IDs so it will fail with a paramErr (-50) on some volumes (mostly old
  1029. external file systems or file servers that haven't been updated for System 7
  1030. features).  That means you can't do the safe-save thing on those volumes
  1031. without adding your own code (which will look a *lot* like the code in
  1032. FSpExchangeFilesCompat).
  1033.  
  1034. - Jim Luther
  1035.  
  1036.  
  1037. ---------------------------
  1038.  
  1039. >From andrew@random.demon.co.uk (Andrew Walker)
  1040. Subject: Looping sounds
  1041. Date: Sat, 14 May 1994 10:05:24 GMT
  1042. Organization: Inner Workings
  1043.  
  1044.  
  1045.  
  1046. How can I get a sound to loop?
  1047.  
  1048. What I would like to acheive is to set up a channel which is dedicated to
  1049. playing a 10 second piece of music over and over again. I have been trying
  1050. to acheive this using the callBackCmd command but up until now I have been
  1051. unsucessful.
  1052.  
  1053. Is there anyone out there with any advice on how to acheive this?
  1054.  
  1055.  
  1056. cheers,
  1057. Andrew.
  1058.  
  1059. =========================================================================
  1060. Andrew Walker - Inner Workings, Suite 406, The Pentagon Centre,  
  1061.                                 36 Washington Street, Glasgow, UK, G3 8AZ
  1062. INTERNET:- andrew@random.demon.co.uk
  1063. Compuserve:- 100102,1634
  1064.  
  1065.  
  1066.  
  1067.  
  1068. +++++++++++++++++++++++++++
  1069.  
  1070. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  1071. Date: Sat, 14 May 1994 13:19:55 GMT
  1072. Organization: Best Before Yesterday
  1073.  
  1074. In article <43@random.demon.co.uk>, andrew@random.demon.co.uk (Andrew
  1075. Walker) wrote:
  1076.  
  1077. > How can I get a sound to loop?
  1078. > What I would like to acheive is to set up a channel which is dedicated to
  1079. > playing a 10 second piece of music over and over again. I have been trying
  1080. > to acheive this using the callBackCmd command but up until now I have been
  1081. > unsucessful.
  1082. > Is there anyone out there with any advice on how to acheive this?
  1083.  
  1084.    In a call back routine (when your sound finishes playing), you can't
  1085. play the sound again, because the callback is an interrupt so playing a
  1086. sound may move or purge memory.
  1087.  
  1088.    There are two solutions:
  1089.  
  1090. just send the sound to the channel as many times as you like (hundreds if
  1091. necessary). Make sure your sound channel queue length is big enough.
  1092.  
  1093. or
  1094.  
  1095. in your call back, set a global boolean saying "play again". Then,
  1096. continuously call a routine in your main loop of your application which
  1097. checks this boolean and starts the sound off if its true.
  1098.  
  1099. in order to set the global boolean in your callback, you'll need to sent
  1100. the current A5 setting as a parameter to the callback routine. You'll need
  1101. GetA5 and SetA5.
  1102.  
  1103.  
  1104. This second method will work indefinitely, but there will be a very small
  1105. pause between the end of the sound and the time it takes to start it
  1106. playing again.
  1107.  
  1108. Hope this helps,
  1109.  
  1110.  
  1111.  
  1112. Alex
  1113.  
  1114. --
  1115. Alex Metcalf, Best Before Yesterday
  1116. Mac programmer in C, C++, HyperTalk, assembler
  1117.  
  1118. Internet, AOL, BIX: alex@metcalf.demon.co.uk            "Surely you
  1119. AppleLink:          alex@metcalf.demon.co.uk@internet#   can't be
  1120. CompuServe:         INTERNET:alex@metcalf.demon.co.uk    serious?"
  1121. Delphi:             alex@metcalf.demon.co.uk@inet#
  1122. FirstClass:         alex@metcalf.demon.co.uk,Internet   "I am serious...
  1123. Fax (UK):           (0570) 45636                         and don't call
  1124. Fax (US / Canada):  011 44 570 45636                     me Shirley."
  1125.  
  1126. +++++++++++++++++++++++++++
  1127.  
  1128. >From kluev@jonathan.srcc.msu.su (Kluev)
  1129. Date: Sun, 15 May 94 20:31:21 +0400
  1130. Organization: (none)
  1131.  
  1132. In article <43@random.demon.co.uk> alex@metcalf.demon.co.uk (Alex
  1133. Metcalf) wrote:
  1134.  
  1135. >In article <43@random.demon.co.uk>, andrew@random.demon.co.uk (Andrew
  1136. >Walker) wrote:
  1137.  
  1138. >> How can I get a sound to loop?
  1139. >> 
  1140. >> What I would like to acheive is to set up a channel which is
  1141. dedicated to
  1142. >> playing a 10 second piece of music over and over again. I have been
  1143. trying
  1144. >> to acheive this using the callBackCmd command but up until now I
  1145. have been
  1146. >> unsucessful.
  1147. >> 
  1148. >> Is there anyone out there with any advice on how to acheive this?
  1149.  
  1150. >   In a call back routine (when your sound finishes playing), you
  1151. can't
  1152. >play the sound again, because the callback is an interrupt so playing
  1153. a
  1154. >sound may move or purge memory.
  1155.  
  1156. There was a thread about PlayingSoundAtInterruptTime some time ago,
  1157. Here are extracts from there.
  1158.  
  1159. You *CAN* play sound in callback procedure. Yes it is interrupt time
  1160. and you can't issue some sound commands like "reinitCmd", "freeCmd"
  1161. (via SndDisposeChannel), etc., i.e. commands that moves memory. But
  1162. you can issue commands like "bufferCmd" to play sounds. By the way,
  1163. QuickTime use this technique.
  1164.  
  1165. Note however that with the presence of new sound manager (3.0)
  1166. bufferCmd, sometimes needs to reconfigure channel. This happened
  1167. when you start to play a "different sort" of sound. By "sort" I mean
  1168. "Compressed or No", SampleRate, SampleSize, ... (May be this list is
  1169. not exact). So to ensure that SM will not reconfigure channel (read:
  1170. Move Memory) at interrupt time - issue first bufferCmd at main time,
  1171. and feel free to call other bufferCmds at interrupt time (PROVIDED
  1172. they are the same sort sound commands). Then, whenever you want to
  1173. play different sort of sound - repeat from the beginning -
  1174. First command at main, other commands at callback.
  1175.  
  1176. The original poster's question was about sound looping: this can
  1177. be done also by modifying loopStart and loopEnd fields, "installing
  1178. sound as a voice" (using soundCmd) (IM VI terminology), and
  1179. issuing freqCmd or freqDurationCmd. All this can be done within
  1180. 'snd' resource, so you can just SndPlay on this resource and it will
  1181. play forever.
  1182.  
  1183. Michael Kluev.
  1184.  
  1185. +++++++++++++++++++++++++++
  1186.  
  1187. >From folta@netcom.com (Steve Folta)
  1188. Date: Mon, 16 May 1994 07:32:31 GMT
  1189. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1190.  
  1191. andrew@random.demon.co.uk (Andrew Walker) writes:
  1192. >How can I get a sound to loop?
  1193.  
  1194. Install the sound with a soundCmd, start playing it with a freqCmd, stop 
  1195. it with a restCmd or quietCmd.  If you want the sound to play out when 
  1196. you stop the looping, make sure your restCmd has a long enough duration.  
  1197. You can use a callBackCmd after the restCmd to set a flag when the sound 
  1198. is done, so you'll know when it's safe to dispose the sound (and the 
  1199. channel if you're not going to reuse it).
  1200.  
  1201. Oh yeah, and make sure the looping points are set in the sound resource.
  1202.  
  1203. -- 
  1204. Steve Folta
  1205. folta@netcom.com
  1206.  
  1207. +++++++++++++++++++++++++++
  1208.  
  1209. >From Thomas Reed <reed@medicine.wustl.edu>
  1210. Date: 16 May 1994 14:52:05 GMT
  1211. Organization: Washington University
  1212.  
  1213. In article <alex-140594141810@metcalf.demon.co.uk> Alex Metcalf,
  1214. alex@metcalf.demon.co.uk writes:
  1215. >just send the sound to the channel as many times as you like
  1216. >or
  1217. >in your call back, set a global boolean saying "play again".
  1218. >
  1219. >This second method will work indefinitely, but there will be a very small
  1220. >pause between the end of the sound and the time it takes to start it
  1221. >playing again.
  1222.  
  1223. I wrote a small test program that uses the second method, and it works
  1224. pretty well, with no pause most places.  Of course, to manage this, you
  1225. have to keep the sound channel open constantly, which, I've heard, can
  1226. play havoc with other things.
  1227.  
  1228. One combination of these two methods would be to constantly keep two
  1229. sounds in the queue.  When the one that's playing finishes, the next one
  1230. will start playing, and you send the next sound into the queue.  Doesn't
  1231. need as big a queue, and there won't be any pause anywhere.  (Well, not
  1232. counting disk accesses or stuff like that.)
  1233.  
  1234. If the original poster (or anyone else, for that matter) is interested in
  1235. seeing my asynch sounds library, I'd be willing to e-mail it.
  1236.  
  1237. -Thomas
  1238. =====================================================
  1239. Thomas Reed                    Washington University
  1240. Reed@telesphere.wustl.edu          Medical School
  1241. (also:  Reed@medicine.wustl.edu)
  1242. - ---------------------------------------------------
  1243. Clothes make the man.  Naked people have little or no
  1244. influence on society.  -- Mark Twain
  1245. =====================================================
  1246.  
  1247. ---------------------------
  1248.  
  1249. >From zwelch@nyx.cs.du.edu (Zach Welch)
  1250. Subject: PPC Toolbox GetDefaultUser() bug
  1251. Date: Sat, 7 May 94 20:57:54 GMT
  1252. Organization: Nyx, Public Access Unix at U. of Denver Math/CS dept.
  1253.  
  1254. Has anyone else out there had the problems I have had with the PPC Toolbox
  1255. call GetDefaultUser()?  I am using Symantec C++ 7.0 (I've tried it with
  1256. 6.0 as well).  I called Symantec Tech Support, and they couldn't get it to
  1257. work either.  Every time I try to make the call, I get the error return code
  1258. noLoggedInErr (-923).  The information in the Sharing Setup control panel
  1259. is all valid, so that's not the problem.  All I'm trying to do is get the
  1260. name that appears there.  I know that the info is saved in the Users & Groups
  1261. Prefs file, thought I more than a little hesitant to try to hack the format.
  1262. If anyone has any idea as to why this call always fails, please let me know.
  1263.  
  1264. Zach
  1265. `
  1266.  
  1267. +++++++++++++++++++++++++++
  1268.  
  1269. >From jumplong@aol.com (Jump Long)
  1270. Date: 14 May 1994 01:51:04 -0400
  1271. Organization: America Online, Inc. (1-800-827-6364)
  1272.  
  1273. In article <1994May7.205754.23878@mnemosyne.cs.du.edu>, zwelch@nyx.cs.du.edu
  1274. (Zach Welch) writes:
  1275.  
  1276. >Every time I try to make the call, I get the error return code
  1277. >noLoggedInErr (-923).
  1278.  
  1279. That error means the default user reference hasn't been used yet, or that it
  1280. has been deleted.  "Huh, what's the default user reference" you say?  Let me
  1281. explain...
  1282.  
  1283. Each time a PPC Toolbox session is authenticated, PPCStart() (via
  1284. StartSecureSession()) returns a user reference number that's associated with
  1285. the user name/password combination entered.  That user reference number can be
  1286. used to reopen a closed PPC Toolbox session using PPCStart() (and thus
  1287. bypassing the user authentication dialog).  One user reference number is
  1288. special, the default user reference number. The default user reference number
  1289. is associated with the user name/password combination that was entered in the
  1290. Sharing Setup control panel and is created the first time a PPC connection is
  1291. opened using that particular user name/password combination.
  1292.  
  1293. So, if you call GetDefaultUser() and get the error noLoggedInErr, it means that
  1294. either: a) the user hasn't authenticated a PPC Toolbox session using their
  1295. default name and password, or b) some piece of code has deleted the default
  1296. user reference number with DeleteUserIdentity().
  1297.  
  1298. By the way, the Event PPC code (what the Apple Event Manager uses to open PPC
  1299. sessions) has a bug in that is deletes all user reference numbers returned by
  1300. StartSecureSession().  It should only delete the non-default user reference
  1301. numbers as shown in the example code on  page 7-36 of Inside Macintosh volume
  1302. VI. Fortunately, I believe it has been fixed for the future.
  1303.  
  1304. I hope that explains PPC Toolbox user reference numbers better than IM did. 
  1305. User reference numbers were somewhat of a mystery to me when I reviewed that
  1306. chapter of Inside Macintosh, but after we shipped System 7, I got to answer
  1307. enough questions about them that I ended up digging the PPC Toolbox's sources
  1308. to find out what they're really used for.
  1309.  
  1310. - Jim Luther
  1311.  
  1312.  
  1313. ---------------------------
  1314.  
  1315. >From dazuma@cco.caltech.edu (Daniel Azuma)
  1316. Subject: SU3.0 programming tip
  1317. Date: Mon, 16 May 1994 07:10:45 -0700
  1318. Organization: California Institute of Technology, Pasadena
  1319.  
  1320. Just a few quick things about programming with System Update 3.0 in mind. 
  1321. Some of us at TopSoft ran into these problems while debugging an alpha of
  1322. FilterTop.
  1323.  
  1324. We use a custom GetFile dialog to get a set of files.  Similarly to THINK's
  1325. and CodeWarrior's "add files..." commands, this dialog "adds" the files
  1326. from the Standard File's list into a custom list below, and then opens the
  1327. files en masse when the user clicks "done".
  1328.  
  1329. Our first problem was that, starting with SU 3.0, it appears that passing
  1330. sfItemOpenButton back from the DlogHook does NOT dismiss the dialog IF no
  1331. items are selected in the Standard File package's main list.  We were
  1332. mapping presses of our "done" button to sfItemOpenButton in order to
  1333. dismiss the dialog, and all of a sudden, that stopped working in the case
  1334. where we had items present in our "to add" list but nothing actually
  1335. selected in the Standard File's main list.  This wasn't happening before we
  1336. installed SU 3!!  The solution, should you run into this, is to return
  1337. sfItemCancelButton instead from your DlogHook, whenever you want to dismiss
  1338. the dialog and it is possible that nothing is selected in the Standard
  1339. File's main list.
  1340.  
  1341. The second problem has to do with the new (very cool) color icons.  There
  1342. are certain circumstances when they're not color!  One notable example is
  1343. the Open... dialog in Microsoft Word (definitely version 5.1a, but probably
  1344. all the others as well).  The reason is, if you use a custom "DLOG"
  1345. resource for your GetFile dialog, you also need to include a "dctb"
  1346. resource in order for it to plot color icons.  The easiest way to add a
  1347. "dctb" resource is to do the following:
  1348. 1) Open the appropriate "DLOG" resource in ResEdit 2.1.1.
  1349. 2) Change the color option radio button to "custom".
  1350. 3) Use the pop-ups to change one of the colors (doesn't matter which one).
  1351. 4) Click ok in the alert that pops up.
  1352. 5) Use the pop-ups to change the color BACK to what it was.
  1353.  
  1354. Hope this makes life easier for someone!
  1355.  
  1356. -Dan
  1357.  
  1358. (Thanks to George Tempel and Jim Brunner for their help in tracking this
  1359. down.)
  1360.  
  1361.  
  1362. _______________________________________________________________________
  1363.  Daniel Azuma            | "Life's bad enough as it is without wanting
  1364.  Caltech                 |  to invent any more of it."
  1365.  dazuma@cco.caltech.edu  |                             --Douglas Adams
  1366.  
  1367. ---------------------------
  1368.  
  1369. End of C.S.M.P. Digest
  1370. **********************
  1371.  
  1372.  
  1373.  
  1374.